#include "../inc/myApplet.h"

namespace Sky
{
	

	Bool myApplet::init()
	{
		mApp.Initialise(&mSetting);
		m_Managers.setRoot(this);
		m_Managers.attachFirstChildOf(this,TreeMgr::cast(&m_EventManager));
		m_Managers.attachNextSiblingOf(TreeMgr::cast(&m_EventManager),TreeMgr::cast(&m_ResManager));
		m_Managers.attachNextSiblingOf(TreeMgr::cast(&m_ResManager),TreeMgr::cast(&m_WinManager));
		return vTrue;
	}

	MsgStatus myApplet::handleSendEvent( myMsgMgr* mgr,Msg* event )
	{
		if(vIntercepted == onSendEvent(mgr,event))
			return vIntercepted;
		if(event->isKindOf(myAppMessage::Class))
		{
			if(vIntercepted == (this->*event->getEvent())(mgr,event))
				return vIntercepted;
		}
		return vContinue;
	}

	Sky::NValue::MsgStatus myApplet::onSendEvent( myMsgMgr* sender,Msg* event )
	{
		if(event->isKindOf(myWinMsg::Class))
		{
			if(vIntercepted == m_WinManager.handleSendEvent(sender,event))
			return vIntercepted;
		}
		return vContinue;
	}

	Sky::NValue::MsgStatus myApplet::handleInput( myMsgMgr* mgr,Msg* event )
	{
		if(vIntercepted == onInput(mgr,event))return vIntercepted;
		return invokeDelegate(mgr,event);
	}

	Sky::NValue::MsgStatus myApplet::onInput( myMsgMgr* mgr,Msg* event )
	{
		return vContinue;
	}

	Sky::NValue::MsgStatus myApplet::handleDeleted( myMsgMgr* mgr,Msg* event )
	{
		if(vIntercepted == onDeleted(mgr,event))return vIntercepted;
		return invokeDelegate(mgr,event);
	}

	Sky::NValue::MsgStatus myApplet::onDeleted( myMsgMgr* sender,Msg* event )
	{
		return vContinue;
	}

}
